package com.jm.web.builder;

import java.io.IOException;

import com.jm.utils.StringBuilderEx;

public class LayoutBuilder extends BaseBuilder{
	@Override
	public void RenderStart() {
		if(this.getBaseTag().getPage().isExport())
			return ;
		
		StringBuilderEx sb = new StringBuilderEx();
		if(this.getBaseTag().getPage().isBorderLayout()){
			sb.Append("<div");
			sb.Append(" class=\"ui-layout-%1$s\"",this.getBaseTag().GetExtValue("postion",""));
			sb.Append(" id=\"%1$s\"",this.getBaseTag().GetExtValue("postion",""));
			sb.Append(" >");
		}else{
			sb.Append("<div");
			sb.Append(" class=\"%1$s\"",this.getBaseTag().GetExtValue("postion",""));
			sb.Append(" id=\"%1$s\"",this.getBaseTag().GetExtValue("postion",""));
			sb.Append(" style=\"%1$s\"",this.getBaseTag().GetExtValue("style",""));
			sb.Append(" ><div style=\"+zoom:1;z-index:0;\" > ");
		}
		try {
			this.getOut().write(sb.toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	public void RenderEnd() {
		if(this.getBaseTag().getPage().isExport())
			return ;
		try {
			if(this.getBaseTag().getPage().isBorderLayout()){
				this.getOut().write("</div>");
			}else{
				this.getOut().write("</div><div style=\"clear: both;display: block\"></div></div>");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
